/**
 * @description  : 大案快报文书 公共方法
 * @descriptionDetail : 大案快报文书 公共方法
 * @copyright    : 浙江烟草
 * @author       : mc
 * @create       : 2022-12-05 15:50:38
 */
import commonService from "@/service/common/common.service";
const caseCommon = {

  data() {
    return {
      state: {
        canEdit: undefined,
        audit: undefined,
      },
      caseParam:{}, // 上个页面传过来的参数
      justView: false,
      docFields:[],
    }
  },
  methods: {
    docBigCaseStep(cb) {
      let param = this.caseParam;
      this.justView = this.caseParam.justView;
      if(param.id){
        commonService.getDocIns(param.id).then(abs => {
          if (!abs.success) return;
          let res = abs.bean;
          param.type = res.step;
          this.state.canEdit = res.step === 'edit' || res.stepName == '开始';
          if(this.state.canEdit){
            this.state.canEdit = !this.justView;
          }
          this.state.audit = res.step === '01';
          cb && cb(res);
        }).catch(e => {
          cb && cb();
        });
      }else{
        commonService.getById(param.docUuid).then(abs => {
          if (!abs.success) return;
          let dc = abs.bean;
          this.state.canEdit = true;
          this.state.canEdit = !this.justView;
          dc.bizUuid = param.bizUuid;
          cb && cb(dc);
        });
      }
    },
  },
}

export default caseCommon;